package com.hbnu.system.controller;


import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.Workproject;
import com.hbnu.system.service.IWorkprojectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-05-16
 */
@RestController
@RequestMapping("/workproject")
@Api(tags = "著作关联项目模块")
public class WorkprojectController {
    @Autowired
    IWorkprojectService iworkprojectService;

    @ApiOperation("著作关联项目添加")
    @PostMapping("/AddWorkProject")
    public Rest<Boolean> AddworkProject(@RequestBody Workproject workproject){
        boolean add = iworkprojectService.addWorkProject(workproject);
        return add ? Rest.success() : Rest.failed();
    }

    @ApiOperation("著作关联项目删除")
    @GetMapping("/RemoveWorkProject")
    public Rest<Boolean> RemoveworkProject(String workProjectID){
        boolean remove = iworkprojectService.removeworkProject(workProjectID);
        return remove ? Rest.success() : Rest.failed();
    }

    @ApiOperation("著作关联项目更新")
    @PostMapping("/UpdateWorkProject")
    public Rest<Boolean> UpdateWorkProject(@RequestBody Workproject workproject){
        boolean update = iworkprojectService.updateWorkProject(workproject);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("著作关联项目查询")
    @GetMapping("/GetWorkProjectByWorkID")
    public Rest<List<Workproject>> GetWorkProjectByWorkID(String workID){
        List<Workproject> workProjectByWorkID = iworkprojectService.getWorkProjectByWorkID(workID);
        return Rest.success(workProjectByWorkID);
    }
}

